<?php
include_once 'library/confirm/MaterialFilterPost.class.php';

$item = new MaterialFilterPost($translator);

// FETCHING
$tgl_perawatan		=	$_POST['tgl_perawatan'];
$label_tandan		=	$_POST['label_tandan'];
$penanggung_jawab	=	$_POST['penanggung_jawab'];
$jml_pekerja		=	$_POST['jml_pekerja'];
$biaya_pekerja		=	$_POST['biaya_pekerja'];

$kondisi_awal		=	$_POST['kondisi_awal'];
$kondisi_akhir		=	$_POST['kondisi_akhir'];
$catatan			=	$_POST['catatan'];

$jenis_perawatan	=	$_POST['jenis_perawatan'];
?>
<div class="title">Konfirmasi - Germinasi</div>
<form name="frm_<?=$subbagian;?>" id="frm_<?=$subbagian;?>" method="post" action="index.php?bagian=<?=$bagian;?>&subbagian=<?=$subbagian;?>&action=confirmed">
    <ul>
    	<li class="header"><span>Identitas Label</span></li>
        <li><span>
            <label>Tanggal Perawatan:</label>
            <span class="confirm"><?=$tgl_perawatan;?></span>
			<input type="hidden" name="tgl_perawatan" value="<?=$tgl_perawatan;?>" />
        </span></li>
         <li><span>
            <label>Label Tandan:</label>
            <span class="confirm"><?=$label_tandan;?></span>
			<input type="hidden" name="label_tandan" value="<?=$label_tandan;?>" />
			<input type="hidden" name="subbagian" value="<?=$subbagian;?>" />
        </span></li>
    </ul>
    <ul>
		<li class="header"><span>Pekerja</span></li>
		<li><span>
            <label>Penanggung Jawab:</label> 
            <span class="confirm"><?=$penanggung_jawab;?></span>
			<input type="hidden" name="penanggung_jawab" value="<?=$penanggung_jawab;?>" />
        </span></li>
		<li><span>
            <label>Jumlah Pekerja:</label> 
            <span class="confirm"><?=$jml_pekerja;?></span>
			<input type="hidden" name="jml_pekerja" value="<?=$jml_pekerja;?>" />
        </span></li>
		<li><span>
            <label>Total Biaya Pekerja:</label> 
            <span class="confirm"><?=$biaya_pekerja;?></span>
			<input type="hidden" name="biaya_pekerja" value="<?=$biaya_pekerja;?>" />
        </span></li>
    </ul>
    <ul id="peralatan">
		<li class="header"><span>Peralatan</span></li>
		<li class="desc">
			<span class="col1">Nama Peralatan</span>
			<span class="col2">Jumlah</span>
		</li>
		<?php
		$no = 0;	
		if( isset($item->peralatan['nama_peralatan']) && count($item->peralatan) ){
			foreach($item->peralatan['nama_peralatan'] as $i=>$v){
				$no++;
				$nama   = $v;
				$jumlah = $item->peralatan['jumlah_peralatan'][$i];
		?>
		<li><span>
			<label><?=$no;?></label>
			<span class="confirm_peralatan_nama"><?=$nama;?></span>
			<span class="confirm_peralatan_jumlah"><?=$jumlah;?></span>
			<input type="hidden" id="nama_peralatan[]" name="nama_peralatan[]" value="<?=$nama;?>"/>
			<input type="hidden" id="jml_peralatan[]" name="jml_peralatan[]" value="<?=$jumlah;?>"/>
		</span>
		<?php 
			}
		}
		?>
	</li> 
    </ul>
    <ul>
		<li class="header"><span>Material</span></li>
		<li class="desc">
			<span class="col1">Nama Material</span>
			<span class="col2">Jumlah</span>
			<span class="col3">Satuan</span>
			<span class="col4">Total Harga</span>
		</li> 
		<?php
		$no 	     = 0;	
		$biaya_total = 0;
		if( isset($item->material['nama_material']) && count($item->material) ){
			foreach($item->material['nama_material'] as $i=>$v){
				$no++;
				$nama   = $translator['nama'][$v];
				$jumlah = $item->material['jumlah_material'][$i];
				$satuan = $item->material['satuan_material'][$i];
				$harga  = $item->material['harga_material'][$i];
				
				$biaya_total += $harga;
		?>
		<li><span>
			<label><?=$no;?></label>
			<span class="confirm_material_nama"><?=$nama;?></span>
			<span class="confirm_material_jumlah"><?=$jumlah;?></span>
			<span class="confirm_material_satuan"><?=$satuan;?></span>
			<span class="confirm_material_harga"><?=$harga;?></span>
			<input type="hidden" id="nama_material[]" name="nama_material[]" value="<?=$nama;?>"/>
			<input type="hidden" id="jml_material[]" name="jml_material[]" value="<?=$jumlah;?>"/>
			<input type="hidden" id="satuan_material[]" name="satuan_material[]" value="<?=$satuan;?>"/>
			<input type="hidden" id="harga_material[]" name="harga_material[]" value="<?=$harga;?>"/>
		</span>
		<?php 
			}
		}
		?>
		<input type="hidden" id="biaya_material" name="biaya_material" value="<?=$biaya_total;?>"/>
	</ul>
	<ul>
		<li class="header"><span>Kondisi</span></li>
		<li><span>
            <label>Jenis Perawatan:</label> 
			<span class="confirm confirm_jenis_perawatan_item">
			<?php
				if( count($jenis_perawatan) > 0 ){
					foreach($jenis_perawatan as $jenis){
			?>
				<?=strtoupper($jenis);?>, 
				<input type="hidden" value="<?=$jenis;?>" name="jenis_perawatan[]" />
			<?php
				}
			}
			?>
			</span>
        </span></li>
		<li><span>
            <label>Kondisi Awal:</label> 
			<span class="confirm"><?=$kondisi_awal;?></span>
			<input type="hidden" name="kondisi_awal" value="<?=$kondisi_awal;?>" />
        </span></li>
		<li><span>
            <label>Kondisi Akhir:</label> 
			<span class="confirm"><?=$kondisi_akhir;?></span>
			<input type="hidden" name="kondisi_akhir" value="<?=$kondisi_akhir;?>" />
        </span></li>
		<li><span>
            <label>Catatan:</label> 
			<span class="confirm"><?=$catatan;?></span>
			<input type="hidden" name="catatan" value="<?=$catatan;?>" />
        </span></li>
    </ul>
	<ul>
		<li class="header"><span>Simpan</span></li>
		<li class="button"><span>
			<input type="submit" name="submit" id="submit" value="Simpan Data" class="simpan"/>
			<a class="cancel" href="#" onclick="javascript:history.go(-1);">Batalkan</a>
		</span></li>
	</ul>
</form>